﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Threading;

namespace BaseHelper.Text
{
    public class TextToRtfFile
    {

        public static string SaveRTF(string TempFullPath,string Text,string FixName="")
        {

            Random rnd = new Random();
            //2018.11.12  因为修改为2.0，无法使用了，暂时屏蔽rtf;
            //.NET 4.0
            Text = ToolsHelper.StrToHtml(Text);
            HtmlToRtf.HtmlToRtfConverter convert = new HtmlToRtf.HtmlToRtfConverter();
            string RTF = convert.ConvertHtmlToRtf(Text);
            string Path = TempFullPath +  FixName + rnd.Next(100000, 999999).ToString() + DateTime.Now.Ticks.ToString() + ".rtf";
            File.WriteAllText(Path, RTF, Encoding.Default);
            return Path;
        }

        public static string SaveText(string TempFullPath,string Text, string FixName = "")
        {
            Random rnd = new Random();
            string Path = TempFullPath  + "\\" + FixName + rnd.Next(100000, 999999).ToString() + DateTime.Now.Ticks.ToString() + ".txt";
            File.AppendAllText(Path, Text, Encoding.Default);
            return Path;
        }



    }
}
